package test2;
import java.util.Scanner;
import static java.lang.Math.max;

public class test2 {

public static void main(string[] args) {

Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();

int[]nums = new int[n];

for(inti=0;i<n;i++)nums[i]=scanner.nextInt();
int mx=nums[0],s=0;
for(inti=0;i<n;i++){
s=max(s+nums[i],nums[i]);
mx=max(mx,s);

System.out.println(mx);

